package com.blackholemax.algorithm.twoPointers;

/**
 * 删除有序数组中的重复项
 */
public class removeDuplicates {
    public static int deleteDuplicates(int[] nums) {
        int j = 1;
        for (int i = 1; i < nums.length; i++) {
            if (nums[i] != nums[i - 1]) {
                nums[j] = nums[i];
                j++;
            }
        }
        return j;
    }

    public static void main(String[] args) {
        int[] nums = {1, 1, 1, 2, 2, 3};
        System.out.println(deleteDuplicates(nums));
    }
}
